#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QMessageBox>
#include <QTime>
#include <QTimer>
#include <QSettings>
#include <QProcess>
#include <QWebPage>
#include <QTcpSocket>
#include <QSystemTrayIcon>
#include <QCloseEvent>
#include <QtGui/QIcon>
#include <QtDebug>   //调试时使用

using namespace std;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    QNetworkAccessManager* ctwlan;
    void sleep(unsigned int msec);
    void systray();
    void closeEvent(QCloseEvent *event);

    string ctRSApwd;
    QSettings ctuserpass;
    QString ctrsakey;
    QDateTime kortimeunix;
    QTcpSocket ncsi;
    QTimer *timer;

    int nCTLanConnect;
    int nWANConnect;
    int isRedial;
    int haveError;
    
private slots:
    void finishedSlot(QNetworkReply *reply);
    void on_pbLogin_clicked();
    void webrsa_reload();

    void on_pbDisconnect_clicked();

    void on_actionDebug_toggled(bool arg1);

    void on_actionAbout_triggered();
    void onTime();
    void onWANconnected();
    void onCTLanconnected();
    void onUserLogin(int isPushed);

    void on_actionExit_triggered();

private:
    Ui::MainWindow *ui;

    QSystemTrayIcon* systemTray;
    QAction* minimumAct;
    QAction* maximumAct;
    QAction* restoreAct;
    QAction* quitAct;
    QMenu* pContextMenu;
};

class QWebPageIE : public QWebPage  //调用IE的UA独立类
{
    Q_OBJECT
public:
    QString userAgentForUrl ( const QUrl & url ) const;
};

#endif // MAINWINDOW_H
